class right{
    constructor(){
        this.url = "http://localhost:3000/api"
        this.ri = document.querySelectorAll(".fl_ri")
        this.goods = document.querySelector(".goods")
        this.bboss = document.querySelector(".bboss")
        this.add = document.querySelector(".add")
        this.load()
    }
    load(){
        ajax({
            url:this.url,
            data:{
                type:"getGoods"
            },
            success:res=>{
                this.res=JSON.parse(res).msg
                this.render()
            }
        })
    }
    render(){
        let str = ""
        this.res.forEach(val=>{
            str+=`<div class="box" index="${val.proId}"> 
                    <div class="pic">
                        <img src="${val.img}" alt="">
                    </div>
                    <div class="info">
                        <p class="name">${val.proName}</p>
                        <p class="sales">已售：${val.sales}件<span class="minnum">起批量：${val.minnum}</span></p>
                        <p class="price">建议零售价：￥<span>${val.price}</span></p>
                    </div>
                    <input type="button" class="add" value="加入购物车">
                </div>`
        })
        this.bboss.innerHTML = str
    }
}
new right()